// 封装api懒加载的方法
import { useIntersectionObserver } from '@vueuse/core'
import { ref } from 'vue'
export function apiLazy (api: () => void) {
  const dom = ref(null)
  const { stop } = useIntersectionObserver(
    dom,
    ([{ isIntersecting }]) => {
      if (isIntersecting) {
        api()
        stop()
      }
    },
    {
      threshold: 0
    }
  )
  return dom
}
